<template>
    <van-nav-bar v-show="isUserAgent" :title="title" :right-text="rigText" @click-right="onClickRight">
        <template #left>
            <van-icon name="cross" size="24" @click="toIndex"/>
        </template>
    </van-nav-bar>
</template>
<script>
import * as dd from 'dingtalk-jsapi';

export default {
    props: ["title", "backTru", "rigText"],
    name: "blockIndexNavBar",
    data: function () {
        return {
            isUserAgent: true,
        }
    },
    mounted() {

        // this.$nextTick(() => {
        //     if (process.env.VUE_APP_MODE == 'mobile') {
        //         this.isUserAgent = tr
        //     }
        // })
        let that = this;
        if (process.env.VUE_APP_MODE == 'mobile') {
            dd.biz.navigation.hideBar({
                hidden: true, // true：隐藏，false：显示
                onSuccess: function (result) {
                },
                onFail: function (err) {
                }
            })
        }

    },
    methods: {
        onClickRight() {
            this.$emit("rightTextClick")
        },
        toIndex() {
            if (typeof this.backTru != "undefined") {
                this.$emit("backMethod")
            } else {
                this.$router.go(-1)
            }
        },
        refresh() {
            location.reload();
        }
    },
    destroyed() {
        if (process.env.VUE_APP_MODE == 'mobile') {
            dd.biz.navigation.hideBar({
                hidden: false, // true：隐藏，false：显示
                onSuccess: function (result) {
                },
                onFail: function (err) {
                }
            })
        }
    }
}

</script>
